package com.cn.dao;

import java.sql.ResultSet;
import java.sql.SQLException;

import com.cn.conn.DataManager;
import com.cn.conn.ParamSet;
import com.cn.conn.RowDatas;
import com.cn.entity.CarConfigure_entity;

/**
 * 车辆详情dao层
 * 
 * @author dell1
 *
 */
public class Car_infoDao extends DataManager {
	private RowDatas<CarConfigure_entity> carinfo;

	public Car_infoDao() {
		carinfo = new Carconfig();
	}

	public CarConfigure_entity  getCarConfigure(String id) {
		String sql = "SELECT d.brand ,"
				+ " b.addressa,b.addressb,b.addressc,b.addressd,"
				+ " c.*"
				+ " FROM tb_car a"
				+ " LEFT JOIN tb_carbrand d ON a.brand = d.id"
				+ " LEFT JOIN tb_carimg b ON a.img = b.id"
				+ " LEFT JOIN tb_carconfigure c ON a.configuration_information = c.id"
				+ " WHERE a.id = ?;";
		 return query(sql, new ParamSet(id), carinfo);
	}

	private class Carconfig implements RowDatas<CarConfigure_entity> {

		@Override
		public CarConfigure_entity getRowData(ResultSet rs) throws SQLException {
			CarConfigure_entity carConfig = new CarConfigure_entity();
			carConfig.setCar_brand(rs.getString("brand"));
			carConfig.setCar_imgA(rs.getString("addressa"));
			carConfig.setCar_imgB(rs.getString("addressb"));
			carConfig.setCar_imgC(rs.getString("addressc"));
			carConfig.setCar_imgD(rs.getString("addressd"));
			carConfig.setDoor_number(rs.getInt("door_number"));
			carConfig.setSeating(rs.getInt("seating"));
			carConfig.setFuel_typpe(rs.getString("fuel_typpe"));
			carConfig.setGear_shift_type(rs.getString("gear_shift_type"));
			carConfig.setDisplacement(rs.getString("displacement"));
			carConfig.setRoz(rs.getString("roz"));
			carConfig.setDrive_mode(rs.getString("drive_mode"));
			carConfig.setEngine_intake_form(rs.getString("engine_intake_form"));
			carConfig.setLouver(rs.getInt("louver"));
			carConfig.setCapacity_of_tank(rs.getInt("capacity_of_tank"));
			carConfig.setVoice_box(rs.getInt("voice_box"));
			carConfig.setSeat(rs.getString("seat"));
			carConfig.setCar_backing_radar(rs.getString("car_backing_radar"));
			carConfig.setGasbag(rs.getInt("gasbag"));
			carConfig.setDvd(rs.getInt("dvd"));
			carConfig.setGps(rs.getString("gps"));
			carConfig.setLablexiang(rs.getString("lablexiang"));
			carConfig.setLablequdon(rs.getString("lablequdon"));
			carConfig.setYear(rs.getString("year"));
			carConfig.setConfiguration_model(rs.getString("configuration_model"));
			carConfig.setCar_series(rs.getString("car_series"));
			
			return carConfig;
		}

	}

}
